﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Business
{
    public static class Validador
    {
        public static bool validarLetraConEspacio(char caracter)
        {
            return ((caracter == 127 || caracter == 8 || caracter == 32) || (caracter == 164 || caracter == 165) || (caracter >= 97 && caracter <= 122) || (caracter >= 65 && caracter <= 90));
        }

        public static bool validarCorreo(char caracter)
        {
            return ((caracter == 127) || (caracter == 8) || (caracter >= 94 && caracter <= 122) || (caracter == 33) || (caracter >= 35 && caracter <= 39) || (caracter >= 42 && caracter <= 57 && caracter != 44) || (caracter == 61) || (caracter == 63) || (caracter == 64));
        }

        public static bool validarNumero(char caracter)
        {
            return ((caracter >= 48 && caracter <= 57) || (caracter == 127 || caracter == 8));       
        }

        public static bool validarNumeroConComa(char caracter)
        {
            return ((caracter >= 48 && caracter <= 57) || (caracter == 127 || caracter == 8) || caracter == 44);
        }

        public static bool validarLetraSinEspacio(char caracter)
        {
            return ((caracter == 127) || (caracter == 8) || (caracter == 164 || caracter == 165) || (caracter >= 97 && caracter <= 122) || (caracter >= 65 && caracter <= 90));
        }

        public static bool campoVacio(string campo)
        {
            return campo.Length == 0;
        }
        public static bool validarEmail(string email)
        {
            string expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";

            if (Regex.IsMatch(email, expresion))
            {
                if (Regex.Replace(email, expresion, String.Empty).Length == 0)
                { return true; }
                else
                { return false; }
            }
            else
            { return false; }
        }
    }
}
